package wheres.the.party;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class SignupActivity extends Activity implements OnClickListener{
	private TextView username,
					 password;
	private Model model;
	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.signup);
        
        model = new Model();
        
        username = (TextView)(findViewById(R.id.username));
        password = (TextView)(findViewById(R.id.password));
        
        Button b = (Button)findViewById(R.id.submit);
        b.setOnClickListener(this);
        
        username.setOnClickListener(this);
        password.setOnClickListener(this);
    }

    @Override
    protected void onStart() {
        super.onStart();
        // The activity is about to become visible.
    }
    @Override
    protected void onResume() {
        super.onResume();
        // The activity has become visible (it is now "resumed").
    }
    @Override
    protected void onPause() {
        super.onPause();
        // Another activity is taking focus (this activity is about to be "paused").
    }
    @Override
    protected void onStop() {
        super.onStop();
        // The activity is no longer visible (it is now "stopped")
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        // The activity is about to be destroyed.
    }
    
	@Override
	public void onClick(View view){
		switch(view.getId()){
			case R.id.username:
				username.setTextColor(0x000000);
				String name = username.getText().toString().toLowerCase();
				String preDef = getString(R.string.username).toLowerCase();
				if(name.equals(preDef)){
					username.setText(null);
				}
				break;
			case R.id.password:
				password.setTextColor(0x000000);
				name = password.getText().toString().toLowerCase();
				preDef = getString(R.string.password).toLowerCase();
				if(name.equals(preDef)){
					password.setText(null);
				}
				break;
			case R.id.submit:
				String s = model.getSignupAnswer(username.getText().toString(), password.getText().toString());
				Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG).show();
				break;
		}
	}
}